home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AM/FM: Amiga Musicians' Freeware Magazine 4
/
AM-FM 4.adf
/
TechCorner
/
audiotest.c
< prev
Wrap
C/C++ Source or Header
|
1991-11-16
|
898b
|
32 lines
#include <exec/types.h>
#include <hardware/custom.h>
#include <hardware/dmabits.h>
#include <stdio.h>
/* This would work even without prototypes, but... */
extern LONG AllocChannels(void);
extern void FreeChannels(void);
/* This is a simple pulse waveform */
static UBYTE chip pulse[] = { -128,-128,-128,-128,127,127,127,127 };
extern struct Custom far custom; /* for audio hardware access */
void main()
{
printf("AM/FM Synthetic sound generator V0.0001\n");
if(AllocChannels()) {
printf("Sorry, but the audio channels are in use.\n");
return;
}
/* Now the channels are ours, exclusively */
custom.aud[0].ac_ptr = (UWORD *)pulse;
custom.aud[0].ac_len = 4;
custom.aud[0].ac_per = 852;
custom.aud[0].ac_vol = 40;
custom.dmacon = DMAF_SETCLR|DMAF_AUD0; /* Audio 0 DMA on */
Delay(50); /* annoy the user for one second */
custom.dmacon = DMAF_AUD0; /* DMA off */
FreeChannels();
}